package com.tanhua.sso.server.controller;

import com.tanhua.result.Result;
import com.tanhua.sso.server.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("comments")
public class CommentsController {

    @Autowired
    private CommentsService commentsService;


    /*发布评论*/
    @PostMapping
    public ResponseEntity comments(@RequestBody Map<String,String> map){
        Integer count = commentsService.comment(map);
        return ResponseEntity.ok(count);
    }

    /*查看评论列表*/
    @GetMapping
    public ResponseEntity getComments(@RequestParam(defaultValue = "1") Integer page,
                                      @RequestParam(defaultValue = "10") Integer pagesize,
                                      String movementId){
        Result result=commentsService.getComments(page,pagesize,movementId);

        return ResponseEntity.ok(result);
    }
}
